<template>
  <div>
    <h3>欢迎您</h3>
    <van-collapse v-model="activeNames" accordion style="width:200px" v-for="i in ziyuan" :key="i.id">
      <van-collapse-item  :title="i.name" >
        <p v-for="j in i['children']" :key="j.id">
          <router-link v-if="i.id==j.pid" name="1" :to="{path:j['url']}">{{j.name}}</router-link>
          <router-link v-else to=""></router-link>
        </p >
      </van-collapse-item>
    </van-collapse>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  name: "zhuye",
  data() {
    return {
      ziyuan: [],
      userid: localStorage.getItem('userid'),
      activeNames:"1"
    }
  },
  methods: {
    get_ziyuan() {
      axios.get('/zuoye/login?userid=' + this.userid).then(res => {
        this.ziyuan = res.data.list
      })
    }
  },
  mounted() {
    this.get_ziyuan()
  }
}
</script>

<style scoped>

</style>